unit Unit3;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm3 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    GroupBox1: TGroupBox;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Button3: TButton;
    SaveDialog1: TSaveDialog;
    procedure FormShow(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form3: TForm3;
  Dir: String;

implementation

uses Unit4;

{$R *.dfm}

procedure TForm3.Button1Click(Sender: TObject);
begin
  Close;
end;

procedure TForm3.Button2Click(Sender: TObject);
begin
  Form4.ShowModal;
end;

procedure TForm3.Button3Click(Sender: TObject);
begin
  if not FileExists(Dir+'Keyset\public.rsa') then
  begin
    ShowMessage('Can''t find the public key. Gen the keyset first!');
    exit;
  end;
  if SaveDialog1.Execute then
  begin
    if not FileExists(SaveDialog1.FileName) then
    begin
      CopyFile(PChar(Dir+'Keyset\public.rsa'),PChar(SaveDialog1.FileName),False);
      if FileExists(SaveDialog1.FileName) then
        ShowMessage('Successfully exported to:'#10#13+SaveDialog1.FileName)
      else
        ShowMessage('Export has failed!');
    end
    else
      Beep();
  end
  else
    Beep();
end;

procedure TForm3.FormCreate(Sender: TObject);
begin
  Dir:=ExtractFilePath(paramstr(0));
end;

procedure TForm3.FormShow(Sender: TObject);
begin
  if FileExists(Dir+'Keyset\private.rsa') then
    Label2.Caption := Dir+'Keyset\private.rsa';
  if FileExists(Dir+'Keyset\public.rsa') then
    Label4.Caption := Dir+'Keyset\public.rsa';

  Label2.Width:=255;
  Label4.Width:=255;
end;

end.
